const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const {VueLoaderPlugin} = require('vue-loader')
const WebpackBar = require('webpackbar')
const chalk = require('chalk')


module.exports = {
  entry: path.resolve(__dirname, '../src/index.js'),

  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, '../dist')
  },

  module: {
    rules: [
      {
        test: /\.vue$/,
        use: ['vue-loader']
      },
      {
        test: /\.less$/,
        use:['vue-style-loader', 'css-loader', 'less-loader']
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      }
    ]
  },

  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, '../public/index.html')
    }),

    new CopyWebpackPlugin({
      patterns: [
        { from: "./public/favicon.ico", to: "../dist" }
      ]
    }),

    new VueLoaderPlugin(),
    new WebpackBar({
      color: "#0f0",  // 默认green，进度条颜色支持HEX
      basic: false,   // 默认true，启用一个简单的日志报告器
      profile:false,  // 默认false，启用探查器。
    })
  ],

  resolve: {
    extensions: ['.js', '.vue'],
    alias: {
      vue: 'vue/dist/vue.esm-browser.js'
    }

  }
}
